<template>
  <div class="container">
    <router-view
     @clickSession="clickSession"

      @backList="backSessionList"/>
  </div>
</template>

<script setup>
import {onBeforeMount } from "vue";
import {useRouter} from "vue-router";
import useSessionStore from "@/store/Session.js";
import useUserStore from "@/store/User.js";

const router = useRouter()
const sessionStore = useSessionStore()
const userStore = useUserStore()

function backSessionList() {
  router.back()
}

function clickSession() {
  router.push({path: '/mini/chat'})
}

onBeforeMount(async () => {
  await Promise.all([userStore.init(), sessionStore.init()])
})
</script>

<style>
.container {
  height: calc(100% - 2px);
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.scroller, .chat {
  max-width: 600px;
  height: 100%;
  border: 1px solid #dee0e3;
  border-radius: 10px;
  padding: 0 20px;
}
</style>
